<%@page import="cn.edu.tjnu.bean.Student"%>
<%@page import="java.util.*,cn.edu.tjnu.bean.Student"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Date date = new Date();
out.write("Hello world..."+date.toString());

//创建一个数组
String[] strArr = new String[]{"张三","lisi","旺旺","zhaoliu"};
//将数组放入request级别的缓存中
request.setAttribute("myArr", strArr);

//java中取出缓存中的数据时
String[] myArr = (String[])request.getAttribute("myArr");
out.write("<br>使用java的for循环解析数组对象：");
for(int i=0;i<myArr.length;i++){
	out.write(myArr[i] + "<br>");
}

//构建一个list+student类的集合数据
List<Student> lstStu = new ArrayList<Student>();
//创建一个学生对象
Student stu0 = new Student();
stu0.setStuName("xiaoming");
stu0.setStuAge(20);
stu0.setStuNum("1300001");
lstStu.add(stu0);

Student stu1 = new Student();
stu1.setStuName("赵六");
stu1.setStuAge(21);
stu1.setStuNum("1300002");
lstStu.add(stu1);
session.setAttribute("lstStu", lstStu);

//构建数据 list+map
List lstMap = new ArrayList();
//创建一个map对象:map的数据结构：  key -- value
Map map0 =  new HashMap();
//向map中填充数据
map0.put("姓名","小明");
map0.put("年龄", 20);
lstMap.add(map0);

Map map1 =  new HashMap();
map1.put("姓名","xiaozhao");
map1.put("年龄", 21);
lstMap.add(map1);

//放入session缓存中
session.setAttribute("lstMap", lstMap);
%>
<c:out value="这里使用out标签进行输出。。。"></c:out>

<p>foreach标签：进行1-10的迭代遍历：</p>
<c:forEach begin = "1" end="10" var="eachVal" step="2">
	"${eachVal}"  -- 
</c:forEach>
<p>foreach标签：迭代数组集合对象</p>
<!-- items ：被迭代的集合对象
var -- 每次迭代出来的值所放入的缓存变量的名称；
varStatus -- 迭代标签的状态数据
 -->
<c:forEach items="${requestScope.myArr }" var="eachVal" varStatus="st">
${st.index +1 } : ${eachVal } <br>
</c:forEach>

<p>foreach标签：迭代list+javaBean集合对象</p>
<c:forEach items="${sessionScope.lstStu }" var="eachStu" varStatus="st">
 ${eachStu.stuName }  
 ${eachStu.stuAge }  
 ${eachStu.stuNum }  <br>
</c:forEach>

<p>foreach标签：嵌套迭代list+map集合对象</p>
<c:forEach items="${lstMap }" var="eachMap" varStatus="st">
 <!-- 嵌套迭代map对象 -->
 <c:forEach  items="${eachMap }" var="eachVal" >
 ${eachVal.key } --- ${eachVal.value }
 </c:forEach>
 <br>
</c:forEach>
</body>
</html>